package com.ccp.dev.im.server.connertor;

import com.ccp.dev.im.server.model.MessageWrapper;
import io.netty.channel.ChannelHandlerContext;

public interface ImConnertor {
	 /**
	  * 发送心跳检测 到客户端
	  * @param hander
	  * @param wrapper
	  */
	void heartbeatToClient(ChannelHandlerContext hander, MessageWrapper wrapper);
	/**
	  * 发送消息
	  * @param wrapper
	  * @throws RuntimeException
	  */
	 void pushMessage(MessageWrapper wrapper) throws RuntimeException;
	 /**
	  * 发送组消息
	  * @param wrapper
	  * @throws RuntimeException
	  */
	 void pushGroupMessage(MessageWrapper wrapper) throws RuntimeException;
	 /**
	  * 发送系统消息
	  * @param  obj     存放值
	  * @param msgType 消息类型
	  * @param userIds 接收人id
	  * @throws RuntimeException
	  */
	 void pushSystemMessage(String obj , int msgType ,  String... userIds) throws RuntimeException;


	 /**
	  * 验证session
	  * @param wrapper
	  * @return
	  * @throws RuntimeException
	  */
	 boolean validateSession(MessageWrapper wrapper) throws RuntimeException;

	 void close(ChannelHandlerContext hander, MessageWrapper wrapper);

	 void close(String sessionId);

	 void close(ChannelHandlerContext hander);

	 void connect(ChannelHandlerContext ctx, MessageWrapper wrapper) ;

	 boolean exist(String sessionId) throws Exception;
	 /**
	  * 发送消息
	  * @param sessionId  发送人
	  * @param wrapper   发送内容
	  * @throws RuntimeException
	  */
	 void pushMessage(String sessionId, MessageWrapper wrapper) throws RuntimeException;
	 /**
	  * 获取用户唯一标识符
	  * @param ctx
	  * @return
	  */
	 String getChannelSessionId(ChannelHandlerContext ctx); 
}
